<?php
use think\facade\Route;
use think\facade\Config;
use think\Response;

Route::group('v1', function () {
Route::group(function () {
    //登录
    Route::get('login', 'v1.LoginController/login')->name('login');
    Route::post('crontab_lz_store', 'v1.CrontabLz/store')->name('crontab_lz_store');
    Route::post('crontab_lz_store_finish', 'v1.CrontabLz/store_finish')->name('crontab_lz_store_finish');
    Route::post('crontab_lz_collection_finnish', 'v1.CrontabLz/collection_finnish')->name('crontab_lz_collection_finnish');

});

//需要授权
Route::group(function () {
    Route::post('authlogin', 'v1.LoginController/authlogin')->name('authlogin');
    Route::get('logout', 'v1.LoginController/logout')->name('logout');// 退出登录
    Route::get('userinfo', 'v1.user.UserController/userinfo')->name('userinfo');// 用户信息

})->middleware(\app\api\middleware\AuthTokenMiddleware::class, true);

})->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\api\middleware\StationOpenMiddleware::class);
//miss 路由
Route::miss(function () {
    if (app()->request->isOptions()) {
        $header = Config::get('cookie.header');
        unset($header['Access-Control-Allow-Credentials']);
        return Response::create('ok')->code(200)->header($header);
    } else
        return Response::create()->code(404);
});